package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author: yingjf
 * @date: 2022/8/17 09:42
 * @description:
 */
@Getter
public enum CompetitorProductFunctionEnum {
    //    完全满足、基本满足、未能满足、完全不满足、未知
    COMPLETELY_SATISFIED("1", "enum.competitorProductFunction.name.completelySatisfied", "completelySatisfied"),
    BASICALLY_SATISFIED("2", "enum.competitorProductFunction.name.basicallySatisfied", "basicallySatisfied"),
    UNSATISFIED("3", "enum.competitorProductFunction.name.unsatisfied", "unsatisfied"),
    COMPLETELY_UNSATISFIED("4", "enum.competitorProductFunction.name.completelyUnsatisfied", "completelyUnsatisfied"),
    UNKNOWN("5", "enum.competitorProductFunction.name.unknown", "unknown"),

    ;
    private String code;
    private String name;
    private String attr;

    CompetitorProductFunctionEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public static CompetitorProductFunctionEnum getByCode(String code) {
        for (CompetitorProductFunctionEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
